package com.example.demo.service;

import com.example.demo.entity.MusicCollection;
import com.example.demo.entity.MusicComment;
import com.example.demo.entity.NoteCollection;
import com.example.demo.mapper.MusicCommentMapper;
import com.example.demo.vo.ViewNoteCommentInfo;
import com.example.demo.vo.ViewNoteCreateInfo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.example.demo.vo.ViewMusicCommentInfo;


import java.util.List;

@Service
public class MusicCommentImpl implements MusicCommentService {
   @Autowired
    private MusicCommentMapper musicCommentMapper;

    @Override
    public PageInfo<ViewMusicCommentInfo> findMusicCommentInfo(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<ViewMusicCommentInfo> list = musicCommentMapper.findMusicCommentInfo();
        PageInfo<ViewMusicCommentInfo> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public PageInfo<MusicComment> findMusicCommentPages(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<MusicComment> lists = musicCommentMapper.findMusicCommentAll();
        PageInfo<MusicComment> pageInfo = new PageInfo<>(lists);  //构造函数，传递函数
        return pageInfo;   //返回pageInfo
    }

    @Override
    public ViewMusicCommentInfo findMusicCommentinfoId(Integer music_comment_id){
        return musicCommentMapper.findMusicCommentinfoId(music_comment_id);
    }

    @Override
    public List<MusicComment> findMusicCommentAll(){
       return musicCommentMapper.findMusicCommentAll();
   }

    @Override
    public MusicComment findMusicCommentDyId(Integer music_comment_id) {
        return musicCommentMapper.findMusicCommentDyId(music_comment_id);
    }

    @Override
    public Integer insertMusicComment(MusicComment musicComment) {
        return musicCommentMapper.insertMusicComment(musicComment);
    }


    @Override
    public Integer updateMusicComment(MusicComment musicComment) {
        return musicCommentMapper.updateMusicComment(musicComment);
    }

    @Override
    public Integer deleteMusicComment(Integer music_comment_id) {
        return musicCommentMapper.deleteMusicComment(music_comment_id);
    }




    //与用户表的用户名、头像相关联，且根据笔记id查找，按点赞量排序
    @Override
    public PageInfo<ViewMusicCommentInfo> findMusicCommentInfomusicid(Integer music_id) {
        List<ViewMusicCommentInfo> list = musicCommentMapper.findMusicCommentInfomusicid(music_id);
        PageInfo<ViewMusicCommentInfo> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }


    //点击举报按钮将会把评论状态从正常修改为被举报
    @Override
    public Integer updateStatus(Integer music_id) {
        return musicCommentMapper.updateStatus(music_id);
    }

    //根据笔记id计数
    @Override
    public Integer countcomment( Integer music_id) {
        return musicCommentMapper.countcomment(music_id);
    }


}
